<?php
class BaseController extends Zend_Controller_Action {

	/**
     * getBaseUrl() - get the baseUrl, where your project runs
     *
     * @return String
     */
	function getBaseUrl() {
		return Zend_Controller_Front::getInstance()->getBaseUrl();
	}
	
	function init() {

	}
	
	function getDBConnection() {
		
		try {
			$db = Zend_Db::factory("Mysqli", array(
			"host" => "localhost",
			"username" => "root",
			"password" => "",
			"dbname" => "zftest"));

		}
		catch (Exception $x) {
			
		}

		return($db);
		
	}	
	
	
	 /**
     * isLoggedIn() - checks if the user is logged in, redirects to index in case of no identity
     */
	function isLogggedIn() {
		$auth = Zend_Auth::getInstance();
		if (!$auth->hasIdentity()) {
			$this->_redirect("index");
		}
	}
	
}
